<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link href="../../plugins/mui/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="../../css/excutive_housekeeper/map.css" />
	    <link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css"/>
	    <script src="http://cache.amap.com/lbs/static/es5.min.js"></script>
		<script type="text/javascript" src="http://webapi.amap.com/maps?v=1.3&key=2781899cbba5f31411b2439cc65cf39a"></script>
		<!--<script type="text/javascript" src="http://cache.amap.com/lbs/static/addToolbar.js"></script>-->
		<style>
			#panel{
				max-width:100%;
				width:100%;
				/*height:100%;*/
				max-height: 100%;
				top:44px;
				right:0;
			}
			/*title的样式覆盖*/
			.mui-bar {
				background-color: #2a2c33;
				z-index: 999;
			}
			.mui-title {
				color: #fff;
			}
			.mui-bar>a{
            	color:#fff;
        	}
		</style>
	</head>
	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left action-back"></a>
			<h1 class="mui-title">地图</h1>
		</header>
		<div id="mapContainer"></div>
		<div id="panel"></div>
		<!--<div id="center">
			<div class="btmtip">前往高德地图查看</div>
			
		</div>-->
		<script src="../../plugins/jquery/jquery-3.1.0.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../plugins/mui/mui.min.js"></script>
		<script type="text/javascript">
		mui.init();
		mui.plusReady(function(){

			$('#panel').delegate('li','tap',function(){
//				console.log($(this).find('.poi-addr').html().substring(2));
//				device($(this).find('.poi-addr').html().substring(2));
				setTimeout(function(){
					$('#panel').hide();
				},500)
			});
			var ws = plus.webview.currentWebview();
			var waiting = plus.nativeUI.showWaiting('正在加载...');
			var address = ws.address;
//				startAddress = ws.startAddress,
//				startPoint = ws.startPoint;
//			getMap(startAddress,address);
//			getSearch(address);
			var map = new AMap.Map("mapContainer", {
		        resizeEnable: true,
		        zoom: 14,
                center:[119.4842219033,31.4169013143]
		    });
		    AMap.service(["AMap.PlaceSearch"], function() {
		        var placeSearch = new AMap.PlaceSearch({ //构造地点查询类
		            pageSize: 5,
		            pageIndex: 1,
		            city: "0519", //城市
		            map: map,
		            panel:'panel'
		        });
		        //关键字查询
		        placeSearch.search(address,function(status, result){
		        	waiting.close();
		        });
		    });
			
		});
		
//		function getSearch(address){
//			var map = new AMap.Map("mapContainer", {
//		        resizeEnable: true,
//		        zoom: 14,
//              center:[119.4842219033,31.4169013143]
//		    });
//		    AMap.service(["AMap.PlaceSearch"], function() {
//		        var placeSearch = new AMap.PlaceSearch({ //构造地点查询类
//		            pageSize: 5,
//		            pageIndex: 1,
//		            city: "0519", //城市
//		            map: map
//		        });
//		        //关键字查询
//		        placeSearch.search(address);
//		    });
//		}
		
//		function getMap(start,end){
//			var button = document.getElementById('center'),
//          	map = new AMap.Map("mapContainer");
//          AMap.plugin(["AMap.Driving"], function() {
//              var drivingOption = {
//                  policy:AMap.DrivingPolicy.LEAST_TIME,
//                  map:map
//              };
//              var driving = new AMap.Driving(drivingOption); //构造驾车导航类
//              //根据起终点坐标规划驾车路线
//              driving.search([{keyword:start},{keyword:end}],function(status,result){
//                  button.onclick = function(){
//                      driving.searchOnAMAP({
//                          origin:result.origin,
//                          destination:result.destination
//                      });
//                  } 
//              });
//              
//          });
//			var map = new AMap.Map("mapContainer");
//			AMap.plugin(["AMap.Driving"], function() {
//          	var drivingOption = {
//	              	policy:AMap.DrivingPolicy.LEAST_TIME,
//	              	map:map
//	          	};
//				var driving = new AMap.Driving(drivingOption); //构造驾车导航类
//	            //根据起终点坐标规划驾车路线
//	            driving.search([{keyword:start},{keyword:end}],function(status,result){
//	            	console.log(status)
//	                if(status == 'complete'){
//	                    driving.searchOnAMAP({
//	                        origin:result.origin,
//	                        destination:result.destination
//	                    });
//	               	}else{
//	               		mui.alert('网络错误');
//	               		mui.back();
//	               	}
//	            });
//       	});
//		}
//		AMap.service('AMap.Geocoder',function(){//回调函数
//			//实例化Geocoder
//			geocoder = new AMap.Geocoder({
//				city: "0519"//城市，默认：“全国”
//			});
//			//TODO: 使用geocoder 对象完成相关功能
//		})
//		function device(path){
//
//			//根据起、终点坐标查询公交换乘路线
//			geocoder.getLocation(path, function(status, result) {
//				if (status === 'complete' && result.info === 'OK') {
//					//TODO:获得了有效经纬度，可以做一些展示工作
//					//比如在获得的经纬度上打上一个Marker
//					console.log(JSON.stringify(result.geocodes[0].location.lng));
//				}else{
//					//获取经纬度失败
//				}
//			});
//
////			trans.search([116.379028, 39.865042], [116.427281, 39.903719], function(status, result) {
////				//TODO:开发者使用result自己创建交互面板和地图展示
////			});
//		}
		</script>
	</body>
</html>
